#include <stdio.h>
#include <sys/time.h>

void sum()
{
	int i;
	int ret = 0;

	for (i = 0;  i <= 100 ; i++)
		ret += i;
	printf("%d\n", ret);
}

void count_time()
{
	struct timeval start, end;
	float  timeuse;

	gettimeofday( &start, NULL );
	sum(); 
	gettimeofday( &end, NULL );
	timeuse = 1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec; 
	timeuse /= 1000000;
	
	printf("timeuse = %f\n", timeuse);
}

void c_time2()
{
	struct timeval tpstart,tpend; 
	float  timeuse; 

	gettimeofday(&tpstart,NULL); 
	sum(); 
	gettimeofday(&tpend,NULL); 
	timeuse = 1000000 * (tpend.tv_sec - tpstart.tv_sec) + tpend.tv_usec - tpstart.tv_usec; 
	timeuse /= 1000000; 
	printf("Used Time:%f\n",timeuse); 
}

int main()
{
	count_time();
	c_time2();
}

